home *** CD-ROM | disk | FTP | other *** search
- /*
- File: HideMenuBar.c
-
- Contains: code snippet for hiding menu bar.
-
- Written by: John Wang
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 03/14/94 JW Re-Created for Universal Headers.
-
- To Do:
-
- */
-
- #ifdef THINK_C
- #define applec
- #endif
-
- #include <Memory.h>
- #include <QuickDraw.h>
- #include <LowMem.h>
-
- #include "HideMenuBar.h"
-
- typedef struct {
- short oldMBarHeight;
- RgnHandle theBarRgn;
- } MenuBarGlobals;
-
- /* ------------------------------------------------------------------------- */
-
- /*
- Description: Call this routine to hide menu bar.
-
- Format Params:
- Name Usage Description/Assumptions
- ---- ---- -----------------------
- return R Returns a handle that must be passed back to RestoreMenuBar().
-
- Usage: P=Parameter,R=ReturnValue,E=External,G=FileGlobal,L=Local,I=Input,O=Output
-
- Error Handling: Return nil if failed.
-
- Special Notes: xxx put other comments here xxx
-
- */
-
- Handle HideMenuBar()
- {
- Rect mBarRect;
- RgnHandle mBarRgn;
- MenuBarGlobals **myHandle;
- Rect myDeviceRect, myMainDeviceRect;
-
- myHandle = (MenuBarGlobals **) NewHandleClear(sizeof(MenuBarGlobals));
- if ( myHandle == nil )
- goto bail;
-
- myMainDeviceRect = (**GetMainDevice()).gdRect;
-
- (**myHandle).oldMBarHeight = GetMBarHeight();
- LMSetMBarHeight(0);
- SetRect(&mBarRect, myMainDeviceRect.left, myMainDeviceRect.top,
- myMainDeviceRect.right, myMainDeviceRect.top + (**myHandle).oldMBarHeight);
- mBarRgn = NewRgn();
- RectRgn(mBarRgn, &mBarRect);
- UnionRgn(LMGetGrayRgn(), mBarRgn, LMGetGrayRgn());
- (**myHandle).theBarRgn = mBarRgn;
-
- bail:
- return( (Handle) myHandle );
- }
-
- /* ------------------------------------------------------------------------- */
-
- /*
- Description: Call this routine to restore menu bar.
-
- Format Params:
- Name Usage Description/Assumptions
- ---- ---- -----------------------
- theHandle PI Contains info to restore menu bar.
-
- Usage: P=Parameter,R=ReturnValue,E=External,G=FileGlobal,L=Local,I=Input,O=Output
-
- Error Handling: If passed nil handle, then just quit.
-
- Special Notes: xxx put other comments here xxx
-
- */
-
- void RestoreMenuBar(Handle theHandle)
- {
- RgnHandle mBarRgn;
- MenuBarGlobals **myHandle;
-
- if (theHandle == nil)
- goto bail;
- myHandle = (MenuBarGlobals **) theHandle;
-
- // Restore menu bar.
- LMSetMBarHeight((**myHandle).oldMBarHeight);
- mBarRgn = (**myHandle).theBarRgn;
- DiffRgn(LMGetGrayRgn(), mBarRgn, LMGetGrayRgn());
- DisposeRgn(mBarRgn);
- DrawMenuBar();
-
- bail:
- if (theHandle != nil)
- DisposHandle(theHandle);
- }